<?php
session_start();
if (isset($_SESSION['openid'])){
    include_once("../c/config.php");
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}
    $openid=$_SESSION['openid'];
    $code=$_POST['code'];
    $cardid=$_POST['cid'];
    $thecode=$_POST['thecode'];
    $lid=$_POST['lid'];
    
    if ('a' != $lid){
        $mysqli->query("update `ling` set thecode='".$thecode."' where id='".$lid."' and jid ='4'  ");
    }else{
        $mysqli->query("update `ling` set thecode='".$thecode."' where openid='".$openid."' and jid ='4' and thecode is NULL ");
    }
     
    $mysqli->query("insert into ucard(openid,name,thecode,cardid,createtime) values('".$openid."','".$code."','".$thecode."','".$cardid."','".date("Y-m-d H:i:s")."') ");
    
    echo 1;
}
?>
